<?php defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' );

/* JoomLeague League Management and Prediction Game for Joomla!
 * Copyright (C) 2007  Robert Moss
 *  
 * Homepage: http://www.joomleague.de
 * Support: htt://www.joomleague.de/forum/
 * 
 * This file is part of JoomLeague.
 *  
 * JoomLeague is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * Please note that the GPL states that any headers in files and
 * Copyright notices as well as credits in headers, source files
 * and output (screens, prints, etc.) can not be removed.
 * You can extend them with your own credits, though...
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 *
 * The "GNU General Public License" (GPL) is available at
 * http://www.gnu.org/copyleft/gpl.html.
*/ 


$config=array();
?>
<a href="" onclick="switchMenu('startingSquads');return false;"><?php echo _JL_STARTING_ROSTERS;?></a>
<div id="startingSquads" style="display:none;"><br />
<table width="100%">
	<tr>
		<th><?php echo $team1->name;?></th><th><?php echo $team2->name;?></th>
	</tr>
	<tr>
		<td><?php
echo mosHTML::selectList( $homesquadoptions, 'homesqad', 'id="homesqad" style="font-size:9px" class="inputbox" multiple="true"','value', 'text', $temphome );?>
		</td><td><?php
echo mosHTML::selectList( $guestsquadoptions, 'awaysqad', 'id="awaysqad" style="font-size:9px" class="inputbox" multiple="true"','value', 'text', $tempaway );?>
		</td>
		<td><input type="button" class="inputbox" value="<?php echo _JL_SAVE;?>" onclick="squads(<?=$match->match_id;?>)" /></td>
	</tr>
</table>
</div><hr />
<form action="" name="myform" id="myform">
<table width="100%">
	<tr>
		<td colspan="3"><b><?php echo _JL_ADMIN_EDIT_FORM_EVENTTYPES_TITLE." "._JL_ADMIN_EDIT_LIST_LMO_IMPORT_CREATE;?></b><br />
	</tr>
	<tr>
		<td width="50%"><b><?php echo $team1->name;?></b></td><td>&nbsp;</td>
		<td width="50%"><b><?php echo $team2->name;?></b></td>
	</tr>
		<tr>
		<td>
<?php
echo '<select name="player_id" id="hometeam" class="inputbox" onchange="if (this.selectedIndex!=0) {document.getElementById(\'guestteam\').disabled=true;} else {document.getElementById(\'guestteam\').disabled=false;}">';
foreach ($homeoptions AS $player_id => $player) {
  echo '<option value="'.$player_id.'"';
  echo '>'.$player.'</option>';
}
echo '</select>';
//echo mosHTML::selectList( $homeoptions, 'player_id', 'id="hometeam" class="inputbox" onchange="if (this.selectedIndex!=0) {document.getElementById(\'guestteam\').disabled=true;} else {document.getElementById(\'guestteam\').disabled=false;}"','id', 'text', 0 );
?></td>
		<td>&nbsp;</td><td>
<?php
echo '<select name="player_id" id="guestteam" class="inputbox" onchange="if (this.selectedIndex!=0) {document.getElementById(\'hometeam\').disabled=true;} else {document.getElementById(\'hometeam\').disabled=false;}">';
foreach ($guestoptions AS $player_id => $player) {
  echo '<option value="'.$player_id.'"';
  echo '>'.$player.'</option>';
}
echo '</select>';
//echo mosHTML::selectList( $guestoptions, 'player_id', 'id="guestteam" class="inputbox" onchange="if (this.selectedIndex!=0) {document.getElementById(\'hometeam\').disabled=true;} else {document.getElementById(\'hometeam\').disabled=false;}"','id', 'text', 0 );?></td>
	</tr>
	<tr>
		<td colspan="3" nowrap="nowrap">
		<input type="hidden" name="mytask" id="mytask" value="save" />
		<input type="hidden" name="func" id="func" value="editEvents" />
		<input type="hidden" name="p" id="p" value="<?php echo $joomleague->id;?>" />
<input type="hidden" name="mid" id="match_id" value="<?php echo $match->match_id;?>" />
<input type="hidden" name="option" id="option" value="com_joomleague" />
<?php echo mosHTML::selectList( $eventtypeoptions, 'event_type_id', 'id="event_type_id" class="inputbox"','value', 'text', '0' );?>
<input type="text" name="event_time" id="event_time" size="3" class="inputbox" value="" /><?php echo _JL_ADMIN_EDIT_FORM_MATCHEVENTS_MINUTE;?>&nbsp;
<?php echo _JL_ADMIN_EDIT_FORM_MATCHEVENTS_NOTICE;?>:&nbsp;<input type="text" name="notice" id="notice" size="20" class="inputbox" value="" />&nbsp;
<a href="javascript:void(0)" onclick="if (document.getElementById('event_sum').style.visibility=='visible'){document.getElementById('event_sum').style.visibility='collapse'} else {document.getElementById('event_sum').style.visibility='visible'}">Anz.:</a>&nbsp;<input type="text" name="event_sum" id="event_sum" size="3" class="inputbox" value="1" default="1" style="visibility:collapse;" />&nbsp;
<input type="button" name="button" value="<?php echo _JL_SAVE;?>" class="inputbox" onclick="javascript:get(document.getElementById('myform'));" />
		</td>
	</tr>
</table>
</form><hr />

<table width="100%">
	<tr>
		<td>
	<br /><a href="" onclick="switchMenu('editEventsArea');return false;"><?php echo _JL_ADMIN_EDIT_FORM_MATCHEVENTS_TITLE._JL_ADMIN_EDIT_FORM_MATCHEVENTS_TITLE_EDIT;?></a><br />
	<br /><div id="editEventsArea" style="display:none;">
	<table style="border: thin;background-color:inherit;width:100%" cellspacing="0" cellpadding="2">
	 	<tr>
	   	<td style="width:50%;background-color:inherit;" valign="top">
<?php
foreach ($eventtypes AS $et) { 
  $max = (isset($sortedevents[$match->match_id][$et->id][$match->matchpart1])) ? count($sortedevents[$match->match_id][$et->id][$match->matchpart1]) : 0;
  for ($x=0;$x<$max;$x++)
  {
   $thiseventid = (isset($sortedevents[$match->match_id][$et->id][$match->matchpart1][$x][5])) ? $sortedevents[$match->match_id][$et->id][$match->matchpart1][$x][5]:0;
						   	echo "<form name=\"$thiseventid\" id=\"$thiseventid\" action=\"\">";
								?>
<?php
    //echo mosHTML::selectList( $eventtypeoptions, 'event_type_id', 'id="event_type_id" class="inputbox" style="font-size:9px"','name', 'value', $et->id );
echo '<select name="event_type_id" id="event_type_id" class="inputbox" style="font-size:9px">';
foreach ($eventtypes AS $type) {
  echo '<option value="'.$type->id.'"';
  if ($type->id == $et->id) echo ' selected="selected"';
  echo '>'.$type->name.'</option>';
}
echo '</select>';
echo '<select name="player_id" id="hometeam" class="inputbox" onchange="if (this.selectedIndex!=0) {document.getElementById(\'guestteam\').disabled=true;} else {document.getElementById(\'guestteam\').disabled=false;}">';
foreach ($homeoptions AS $player_id => $player) {
  echo '<option value="'.$player_id.'"';
  if ($player_id == $sortedevents[$match->match_id][$et->id][$match->matchpart1][$x][0]) echo ' selected="selected"';
  echo '>'.$player.'</option>';
}
echo '</select>';

//mosHTML::selectList( $homeoptions, 'player_id', 'id="player_id" style="font-size:9px" class="inputbox"','name', 'value', $sortedevents[$match->match_id][$et->id][$match->matchpart1][$x][0] );
?>
						        Min:<input type="text" size="3" name="event_time" id="event_time" value="<?php echo $sortedevents[$match->match_id][$et->id][$match->matchpart1][$x][3];?>" class="inputbox" style="font-size:9px" /><br />
						        Anz:<input type="text" size="3" name="event_sum" id="event_sum" value="<?php echo $sortedevents[$match->match_id][$et->id][$match->matchpart1][$x][6];?>" class="inputbox" style="font-size:9px" />
						        <input type="text" size="10" name="notice" id="notice" value="<?php echo $sortedevents[$match->match_id][$et->id][$match->matchpart1][$x][4];?>" class="inputbox" style="font-size:9px" />
						        <input type="button" name="button" value="DEL" class="inputbox" style="font-size:9px" onclick="javascript:ajaxevents('index2.php?option=com_joomleague&func=editEvents&mytask=deleteevent&p=<?=$joomleague->id;?>&no_html=1&evid=<?php echo $thiseventid."&mid=".$match->match_id;?>', 'eventscontainer');" />
						        <input type="button" name="button" value="UPD" class="inputbox" style="font-size:9px" onclick="javascript:update(this.parentNode)" />
						        <input type="hidden" name="evid" id="evid" value="<?php echo $thiseventid;?>" /><hr /></form>
<?php						}
							} ?>
						      </td>
						      <td style="width:50%;background-color:inherit;" valign="top">
<?php
        foreach ($eventtypes AS $et) {
			   	$max = (isset($sortedevents[$match->match_id][$et->id][$match->matchpart2])) ? count($sortedevents[$match->match_id][$et->id][$match->matchpart2]) : 0;
						   for ($x=0;$x<$max;$x++) {
						   	$thiseventid=$sortedevents[$match->match_id][$et->id][$match->matchpart2][$x][5];
						   	echo "<form name=\"$thiseventid\" id=\"$thiseventid\" action=\"\">";
						   	?>
								<?php
echo '<select name="event_type_id" id="event_type_id" class="inputbox" style="font-size:9px">';
foreach ($eventtypes AS $type) {
  echo '<option value="'.$type->id.'"';
  if ($type->id == $et->id) echo ' selected="selected"';
  echo '>'.$type->name.'</option>';
}
echo '<select name="player_id" id="hometeam" class="inputbox" onchange="if (this.selectedIndex!=0) {document.getElementById(\'guestteam\').disabled=true;} else {document.getElementById(\'guestteam\').disabled=false;}">';
foreach ($guestoptions AS $player_id => $player) {
  echo '<option value="'.$player_id.'"';
  if ($player_id == $sortedevents[$match->match_id][$et->id][$match->matchpart2][$x][0]) echo ' selected="selected"';
  echo '>'.$player.'</option>';
}
echo '</select>';
//echo mosHTML::selectList( $guestoptions, 'player_id', 'id="player_id" class="inputbox" style="font-size:9px"','value', 'name', $sortedevents[$match->match_id][$et->id][$match->matchpart2][$x][0] );
?>
						        Min:<input type="text" size="3" name="event_time" id="event_time" value="<?php echo $sortedevents[$match->match_id][$et->id][$match->matchpart2][$x][3];?>" class="inputbox" style="font-size:9px" /><br />
						        Anz:<input type="text" size="3" name="event_sum" id="event_sum" value="<?php echo $sortedevents[$match->match_id][$et->id][$match->matchpart2][$x][6];?>" class="inputbox" style="font-size:9px" />
						        <input type="text" size="10" name="notice" id="notice" value="<?php echo $sortedevents[$match->match_id][$et->id][$match->matchpart2][$x][4];?>" style="font-size:9px" class="inputbox" />
						        <input type="button" name="button" value="DEL" class="inputbox" style="font-size:9px" onclick="ajaxevents('index2.php?option=com_joomleague&func=editEvents&mytask=deleteevent&p=<?=$joomleague->id;?>&no_html=1&evid=<?php echo $thiseventid."&mid=".$match->match_id;?>', 'eventscontainer');" />
						        <input type="button" name="button" value="UPD" class="inputbox" style="font-size:9px" onclick="javascript:update(this.parentNode)" />
						        <input type="hidden" name="evid" id="evid" value="<?php echo $thiseventid;?>" /><hr /></form>
<?php						}
						} ?>
						       </td>
						    </tr>
						    </table>
 </div><? 
?></td>
	</tr>
</table>
</form>
